extension DateTimestamp on DateTime {
  /// The number of seconds since
  /// the "Unix epoch" 1970-01-01T00:00:00Z (UTC).
  ///
  /// This value is independent of the time zone.
  ///
  /// This value is at most
  /// 8,640,000,000,000s (100,000,000 days) from the Unix epoch.
  /// In other words: `secondsSinceEpoch.abs() <= 8640000000000`.
  int get secondsSinceEpoch {
    final t = millisecondsSinceEpoch / 1000;
    return t.toInt();
  }

  /// 是否今天。
  ///
  /// [timestamp] 时间戳，秒。
  static bool isToday(int timestamp) {
    final target = DateTime.fromMillisecondsSinceEpoch(
      timestamp * 1000,
    );
    final now = DateTime.now();
    return now.year == target.year &&
        now.month == target.month &&
        now.day == target.day;
  }
}
